package com.woniuxy.controller.UserRelated;


import com.woniuxy.demo.Result;
import com.woniuxy.dto.RolesAndMenusDto;
import com.woniuxy.service.MenuTableService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author zcx, ftl, gr, rhs
 * @since 2021-12-31
 */
@Api(tags = "菜单信息管理")
@RestController
@RequestMapping("/menu-table")
public class MenuTableController {

    @Resource
    MenuTableService mts;

    /**
     * 根据账号查询关联的菜单
     * @return
     */
    @ApiOperation("查询账号关联菜单")
    @PostMapping("listMenusByUserId.do")
    public Result listMenusByUserId() {
        return Result.newInstance().setCode(200).setMsg("查询成功").setData(mts.listMenusByUserId());
    }

    /**
     * 查询当前角色绑定的所有菜单和勾选状态
     * @param roleId
     * @return
     */
    @ApiOperation("查询当前角色绑定的所有菜单和勾选状态")
    @PostMapping("listMenusByRoleId.do/{roleId}")
    @ApiImplicitParam(name = "roleId", value = "角色id")
    public Result listMenusByRoleId(@PathVariable String roleId) {
        RolesAndMenusDto roleAndMenusDto = mts.listMenusByRoleId(roleId);
        return Result.newInstance().setCode(200).setMsg("查询成功").setData(roleAndMenusDto);
    }
}

